package com.zx.deploy.controller;

import com.zx.deploy.service.DeployService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import com.zx.deploy.config.DeployConfig;

@Controller
public class HomeController implements ErrorController {

	private static final String ERROR_PATH = "/error";

	@Autowired
	private DeployConfig conig;

	@Autowired
	private DeployService deployService;

	/**
	 * 显示首页
	 * 
	 * @return
	 */
	@GetMapping(value = { "/", "/index" })
	public String index(Model model) {
		model.addAllAttributes(deployService.getVersions());
		return "index";
	}
	

	/**
	 * 发生错误页面
	 * 
	 * @return
	 */
	@GetMapping(ERROR_PATH)
	public Object error() {
		return "error";
	}

	public String getErrorPath() {
		return ERROR_PATH;
	}

}
